﻿using System;
using System.Linq;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using RevitInteractiveUtility;

namespace YJKRevitKernel.SampleAndTest
{
	[Transaction(TransactionMode.Manual)]
	public class TestCmdLindDoc : IExternalCommand
	{
		public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
		{
			UIDocument activeUIDocument = commandData.Application.ActiveUIDocument;
			Document document = activeUIDocument.Document;
			Selection selection = activeUIDocument.Selection;
			Element elementToLocate = new FilteredElementCollector((new FilteredElementCollector(document).OfClass(typeof(RevitLinkInstance)).First<Element>() as RevitLinkInstance).GetLinkDocument()).OfClass(typeof(Wall)).First<Element>();
			DoubleCilckToLocate.DoubleClickToLocate(activeUIDocument, document.ActiveView, elementToLocate, document, true);
			return Autodesk.Revit.UI.Result.Succeeded;
		}
	}
}
